﻿<phone:PhoneApplicationPage 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
	xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:System="clr-namespace:System;assembly=mscorlib"
	mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    x:Class="MyDeeWeibo.PageViews.Discoverys"
    Orientation="Portrait"
	shell:SystemTray.IsVisible="True"
    Loaded="PhoneApplicationPage_Loaded"
    xmlns:ImageTools="clr-namespace:ImageTools.Controls;assembly=ImageTools.Controls"
    DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <phone:PhoneApplicationPage.Resources>
        <ImageTools:ImageConverter x:Key="ImageConverter"/>
        <DataTemplate x:Key="StatusTemplateComplex">
            <Grid Margin="0,12,8,10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <StackPanel x:Name="LeftPanel" Orientation="Vertical" d:LayoutOverrides="Height" Margin="0,0,8,0">
                    <Border x:Name="ProfileBorder" BorderThickness="1" Width="64" Height="64" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="{StaticResource TransparentBrush}">
                        <Canvas Margin="0">
                            <Image x:Name="ProfileImage" Source="{Binding user.profile_img}" Height="56" Width="56" Canvas.Left="2" Canvas.Top="2"/>
                            <Image x:Name="VerifyLogo" Height="20" Width="20" Canvas.Left="45" Canvas.Top="45" Source="/Resources/Images/SinaResource.Verifier.png" Visibility="{Binding user.IsVerified}" Stretch="UniformToFill"/>
                        </Canvas>
                    </Border>
                </StackPanel>

                <StackPanel x:Name="RightPanel" Grid.Column="1" Grid.Row="0" Margin="0" Orientation="Vertical" d:LayoutOverrides="Height" >
                    <Grid x:Name="HeaderGrid" Margin="0,4,0,10" UseLayoutRounding="True" Height="30">
                        <Grid.Background>
                            <LinearGradientBrush EndPoint="0.5,0" MappingMode="RelativeToBoundingBox" StartPoint="0.5,1">
                                <GradientStop Color="{Binding Source={StaticResource AppSettings}, Path=colorSaved}" Offset="0"/>
                                <GradientStop Color="Transparent" Offset="0.1"/>
                            </LinearGradientBrush>
                        </Grid.Background>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock x:Name="UserName" Height="30" Margin="-10" FontSize="20" Text="{Binding user.name}" Padding="10,0" Foreground="Black" LineHeight="16" />
                        <TextBlock x:Name="CreateTimeBlock" Text="{Binding CreatedAt}" FontSize="20" VerticalAlignment="Bottom" Grid.Column="1" Foreground="{StaticResource GreyBrush}" Margin="0" Height="30"/>
                    </Grid>
                    <TextBlock x:Name="StatusBlock" Text="{Binding text}" TextWrapping="Wrap" FontSize="21.333" Foreground="Black" />
                    <ImageTools:AnimatedImage x:Name="GifShow" Source="{Binding thumbnail_isgif, Converter={StaticResource ImageConverter}}" HorizontalAlignment="Left" Stretch="Uniform" Visibility="{Binding IsThumbnail}" Margin="0,12,0,0" VerticalAlignment="Top" Height="{Binding thumbnail_isgifheight}"/>
                    <Image x:Name="ThumbImage" Source="{Binding thumbnail_pic}" HorizontalAlignment="Left" Stretch="Uniform" Visibility="{Binding IsThumbnail}" Margin="0,12,0,0" VerticalAlignment="Top" Height="{Binding thumbnail_notgifheight}"/>
                    <Border x:Name="RetweetBorder" Margin="0,12,0,0" Padding="8,12" Visibility="{Binding IsRetweetedStatus}" CornerRadius="10" BorderThickness="1" Background="#FFEDEDED" BorderBrush="#FFC2C2C2">
                        <StackPanel>
                            <TextBlock x:Name="RetweetUserBlock" TextWrapping="Wrap" Text="{Binding retweeted_status.user.name}" Margin="0,0,0,10" Foreground="Black" FontWeight="Bold"/>
                            <TextBlock x:Name="RetweetStatusBlock" TextWrapping="Wrap" Text="{Binding retweeted_status.text}" Foreground="Black"/>
                            <ImageTools:AnimatedImage x:Name="RetweetGifShow" 
                                                      Source="{Binding retweeted_status.thumbnail_isgif, Converter={StaticResource ImageConverter}}" 
                                                      HorizontalAlignment="Left" Stretch="Uniform" Visibility="{Binding retweeted_status.IsThumbnail}" 
                                                      Margin="0,12,0,0" VerticalAlignment="Top" Height="{Binding retweeted_status.thumbnail_isgifheight}"/>
                            <Image x:Name="RetweetThumbImage" 
                                   Margin="0,12,0,0" 
                                   Stretch="Uniform" 
                                   Source="{Binding retweeted_status.thumbnail_pic}" 
                                   Visibility="{Binding retweeted_status.IsThumbnail}" 
                                   HorizontalAlignment="Left" 
                                   VerticalAlignment="Top" 
                                   Height="{Binding retweeted_status.thumbnail_notgifheight}"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <Grid x:Name="FooterGrid" Margin="0,12,0,0" Grid.Row="1" Grid.Column="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <StackPanel x:Name="SourcePanel" Orientation="Horizontal" HorizontalAlignment="Left" d:LayoutOverrides="HorizontalAlignment, GridBox">
                        <Image x:Name="StatusPicHint" Source="/Resources/Images/Status_Pic.png" Visibility="{Binding IsThumbnail}" Margin="0,0,0,-2" Width="30"/>
                        <TextBlock x:Name="SourceBlock"
                        	Text="{Binding Source}" 
                        	d:LayoutOverrides="Width" 
                        	HorizontalAlignment="Left" 
                        	VerticalAlignment="Bottom" 
                        	FontSize="18.667" Foreground="{StaticResource GreyBrush}"/>
                        <Image x:Name="StatusComment" Source="/Resources/Images/Status_Comment.png" Margin="0,0,0,-2" Width="30"/>
                        <TextBlock x:Name="CommentCount"
    						Text="{Binding comments_count}" 
    						d:LayoutOverrides="Width" 
    						HorizontalAlignment="Left" 
    						VerticalAlignment="Bottom" 
    						FontSize="18.667" Foreground="{StaticResource GreyBrush}"/>
                        <Image x:Name="StatusRepost" Source="/Resources/Images/Status_Repost.png" Margin="0,0,0,-2" Width="30"/>
                        <TextBlock x:Name="RepostCount"
    						Text="{Binding reposts_count}" 
    						d:LayoutOverrides="Width" 
    						HorizontalAlignment="Left" 
    						VerticalAlignment="Bottom" 
    						FontSize="18.667" Foreground="{StaticResource GreyBrush}"/>
                    </StackPanel>
                </Grid>

                <Path x:Name="Separater" Data="M0,80 L448,80" Height="1" Margin="0" Grid.Row="2" Grid.ColumnSpan="2" Stretch="Fill" UseLayoutRounding="False" VerticalAlignment="Top" HorizontalAlignment="Center">
                    <Path.Stroke>
                        <SolidColorBrush Color="{StaticResource PhoneForegroundColor}"/>
                    </Path.Stroke>
                </Path>
            </Grid>
        </DataTemplate>
        <ControlTemplate x:Key="ListBoxControlTemplate" TargetType="ListBox" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" 
                          BorderThickness="{TemplateBinding BorderThickness}" 
                          Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}" 
                          Style="{StaticResource CustomScrollViewerStyle}" 
                          ManipulationCompleted="ListBox_ManipulationCompleted">
                <ItemsPresenter/>
            </ScrollViewer>
        </ControlTemplate>
    </phone:PhoneApplicationPage.Resources>

    <phone:PhoneApplicationPage.FontFamily>
        <StaticResource ResourceKey="PhoneFontFamilyNormal"/>
    </phone:PhoneApplicationPage.FontFamily>
    <phone:PhoneApplicationPage.FontSize>
        <StaticResource ResourceKey="PhoneFontSizeNormal"/>
    </phone:PhoneApplicationPage.FontSize>
    <phone:PhoneApplicationPage.Foreground>
        <StaticResource ResourceKey="PhoneForegroundBrush"/>
    </phone:PhoneApplicationPage.Foreground>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="UserSettings" IsEnabled="True" Text="设置" Click="UserSettings_Click"/>
            </shell:ApplicationBar.MenuItems>
            <shell:ApplicationBarIconButton x:Name="refreshIconButton" IconUri="/Resources/Icons/appbar_refresh.png" Text="刷新" Click="refreshIconButton_Click"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Style="{StaticResource BackgroundStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <controls:Pivot x:Name ="MainPivot" Title="{StaticResource AppName}" Foreground="{Binding Source={StaticResource AppSettings}, Path=colorSaved}" SelectionChanged="MainPivot_SelectionChanged" Height="680" >
            <!--Pivot1-->
            <controls:PivotItem x:Name="hotRepost" Header="热门转发" Foreground="Black" Margin="12,0">
                <Grid x:Name="hotRepostPanel" Grid.Row="1" Margin="12,0" >
                    <Grid Height="60" Margin="0" VerticalAlignment="Top">
                        <RadioButton x:Name="RepostDailyButton" Content="本日" Height="80" Margin="70,0,0,0" BorderBrush="{StaticResource GreyBrush}" Foreground="{StaticResource GreyBrush}"  BorderThickness="1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="140" FontSize="18.667" Click="RepostDailyButton_Click" />
                        <RadioButton x:Name="RepostWeeklyButton" Content="本周" Height="80" Margin="0,0,45,0" BorderBrush="{StaticResource GreyBrush}" Foreground="{StaticResource GreyBrush}" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Width="140" FontSize="18.667" Click="RepostWeeklyButton_Click"/>
                        <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Margin="69,16,0,-6" Width="113"/>
                        <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Right" Margin="0,16,73,-6" Width="113"/>
                    </Grid>
                    <ListBox x:Name="hotReposts"
                		ItemsSource="{Binding HotRepostDaily}"
                		ItemTemplate="{StaticResource StatusTemplateComplex}" Foreground="Black" Margin="0,80,0,0" Height="464" HorizontalAlignment="Right" Width="432"
                		SelectionChanged="hotReposts_SelectionChanged" Template="{StaticResource ListBoxControlTemplate}" />
                    <ListBox x:Name="hotRepostsWeek"
                		ItemsSource="{Binding HotRepostWeekly}"
                		ItemTemplate="{StaticResource StatusTemplateComplex}" Foreground="Black" Margin="0,80,0,0" HorizontalAlignment="Right" Width="432"
                		SelectionChanged="hotRepostsWeek_SelectionChanged" Template="{StaticResource ListBoxControlTemplate}" Visibility="Collapsed" Height="464"/>
                    <Button x:Name="toTopButtonRe" HorizontalAlignment="Left" VerticalAlignment="Bottom" 
                            Foreground="{StaticResource TransparentBrush}" 
                            BorderBrush="{StaticResource TransparentBrush}" 
                            Width="80" Height="80" Margin="-25,0,0,-20" Click="toTopButtonRe_Click"
                            Visibility="Collapsed">
                        <Button.Background>
                            <ImageBrush ImageSource="/MyDeeWeibo;component/Resources/Images/toTop.png" Opacity="0.4"/>
                        </Button.Background>
                    </Button>
                </Grid>
            </controls:PivotItem>

            <!--Pivot2-->
            <controls:PivotItem x:Name="hotComment" Header="热门评论" Foreground="Black" Margin="12,0">
                <Grid x:Name="hotCommentPanel" Grid.Row="1" Margin="12,0" >
                    <Grid Height="60" Margin="0" VerticalAlignment="Top">
                        <RadioButton x:Name="CommentDailyButton" Content="本日" Height="80" Margin="70,0,0,0" BorderBrush="{StaticResource GreyBrush}" Foreground="{StaticResource GreyBrush}"  BorderThickness="1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="140" FontSize="18.667" Click="CommentDailyButton_Click" />
                        <RadioButton x:Name="CommentWeeklyButton" Content="本周" Height="80" Margin="0,0,45,0" BorderBrush="{StaticResource GreyBrush}" Foreground="{StaticResource GreyBrush}" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Width="140" FontSize="18.667" Click="CommentWeeklyButton_Click"/>
                        <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Margin="69,16,0,-6" Width="113"/>
                        <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Right" Margin="0,16,73,-6" Width="113"/>
                    </Grid>
                    <ListBox x:Name="hotComments"
                		ItemsSource="{Binding HotCommentDaily}"
                		ItemTemplate="{StaticResource StatusTemplateComplex}" Foreground="Black" Margin="0,80,0,0" Height="464" HorizontalAlignment="Right" Width="432"
                		SelectionChanged="hotComments_SelectionChanged" Template="{StaticResource ListBoxControlTemplate}" />
                    <ListBox x:Name="hotCommentsWeek"
                		ItemsSource="{Binding HotCommentWeekly}"
                		ItemTemplate="{StaticResource StatusTemplateComplex}" Foreground="Black" Margin="0,80,0,0" Height="464" HorizontalAlignment="Right" Width="432"
                		SelectionChanged="hotCommentsWeek_SelectionChanged" Template="{StaticResource ListBoxControlTemplate}" Visibility="Collapsed"/>
                    <Button x:Name="toTopButtonCo" HorizontalAlignment="Left" VerticalAlignment="Bottom" 
                            Foreground="{StaticResource TransparentBrush}" 
                            BorderBrush="{StaticResource TransparentBrush}" 
                            Width="80" Height="80" Margin="-25,0,0,-20" Click="toTopButtonCo_Click"
                            Visibility="Collapsed">
                        <Button.Background>
                            <ImageBrush ImageSource="/MyDeeWeibo;component/Resources/Images/toTop.png" Opacity="0.4"/>
                        </Button.Background>
                    </Button>
                </Grid>
            </controls:PivotItem>

            <!--Pivot3-->
            <controls:PivotItem x:Name="randomStatus" Header="随便看看" Foreground="Black" Margin="12,0">
                <Grid x:Name="randomStatusPanel" Grid.Row="1" Margin="12,0" >
                    <ListBox x:Name="randomStatuses"
                		ItemsSource="{Binding PublicTimelineList}"
                		ItemTemplate="{StaticResource StatusTemplateComplex}" Foreground="Black" Margin="0,1,0,0" HorizontalAlignment="Right" Width="432"
                		SelectionChanged="randomStatuses_SelectionChanged" Template="{StaticResource ListBoxControlTemplate}" />
                </Grid>
            </controls:PivotItem>

            <!--Pivot4-->
            <!--<controls:PivotItem x:Name="favorite" Header="收藏" Foreground="{StaticResource PhoneBackgroundBrush}">
                <Grid x:Name="FavoritePanel" Grid.Row="1" Margin="12,0" Height="531" >
                    <ListBox x:Name="favorites"
                     ItemsSource="{Binding FavoritesList}" 
                     ItemTemplate="{StaticResource FavoritesTemplateComplex}" Foreground="{StaticResource PhoneBackgroundBrush}" Margin="0,1,0,0" Height="530" HorizontalAlignment="Right" Width="432" 
                     SelectionChanged="favorites_SelectionChanged"/>
                </Grid>
            </controls:PivotItem>-->
        </controls:Pivot>
            
        <!--TitlePanel contains the name of the application and page title
		<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
			<TextBlock x:Name="ApplicationTitle" Text="{StaticResource AppName}" Style="{StaticResource PhoneTextNormalStyle}" Foreground="{StaticResource PhoneBackgroundBrush}"/>
			<TextBlock x:Name="PageTitle" Text="Timeline" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" Foreground="{StaticResource PhoneBackgroundBrush}"/>
		</StackPanel>->

		ContentPanel - place additional content here-->

    </Grid>

</phone:PhoneApplicationPage>
